<!DOCTYPE html>


  <html class="dark page-post">


<head><meta name="generator" content="Hexo 3.9.0">
  <meta charset="utf-8">
  
  <title>SqlServer2005学习总结 | Poetry&#39;s Blog</title>

  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

  
    <meta name="keywords" content="sql,">
  

  <meta name="description" content="第一部分：数据库相关概念什么是数据库">
<meta name="keywords" content="sql">
<meta property="og:type" content="article">
<meta property="og:title" content="SqlServer2005学习总结">
<meta property="og:url" content="http://blog.poetries.top/2016/05/17/SqlServer2005学习总结/index.html">
<meta property="og:site_name" content="Poetry&#39;s Blog">
<meta property="og:description" content="第一部分：数据库相关概念什么是数据库">
<meta property="og:locale" content="zh-Hans">
<meta property="og:updated_time" content="2020-08-15T04:25:31.902Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="SqlServer2005学习总结">
<meta name="twitter:description" content="第一部分：数据库相关概念什么是数据库">

  

  
    <link rel="icon" href="/favicon.ico">
  

  <link href="/css/styles.css?v=c114cbeddx" rel="stylesheet">
<link href="/css/other.css?v=c114cbeddx" rel="stylesheet">


  
    <link rel="stylesheet" href="/css/personal-style.css">
  

  

  
  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "//hm.baidu.com/hm.js?40b1f89aa80f2527b3db779c6898c879";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>


  
  <script type="text/javascript">
	(function(){
	    var bp = document.createElement('script');
	    var curProtocol = window.location.protocol.split(':')[0];
	    if (curProtocol === 'https') {
	        bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';        
	    }
	    else {
	        bp.src = 'http://push.zhanzhang.baidu.com/push.js';
	    }
	    var s = document.getElementsByTagName("script")[0];
	    s.parentNode.insertBefore(bp, s);
	})();
  </script>



  
    <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
    <link rel="stylesheet" href="//cdn.bootcss.com/font-awesome/4.3.0/css/font-awesome.min.css">
  

  <!-- 聊天系统 -->
  
    
   <link type="text/css" rel="stylesheet" href="/renxi/default.css">
   <style>
      #modal {
        position: static !important;
      }
      .filter {
        width: 100%;
        height: 100%;
        position: absolute;
        top: 0;
        left: 0;
        background: #fe5757;
        animation: colorChange 30s ease-in-out infinite;
        animation-fill-mode: both;
        mix-blend-mode: overlay;
      }
  
      @keyframes colorChange {
        0%, 100% {
            opacity: 0;
        }
        50% {
            opacity: .9;
        }
      }
   </style>
</head>
</html>
<body>
  
  
    <span id="toolbox-mobile" class="toolbox-mobile">导航</span>
  

  <div class="post-header CENTER">
   
  <div class="toolbox">
    <a class="toolbox-entry" href="/">
      <span class="toolbox-entry-text">导航</span>
      <i class="icon-angle-down"></i>
      <i class="icon-home"></i>
    </a>
    <ul class="list-toolbox">
      
        <li class="item-toolbox">
          <a
            class="CIRCLE"
            href="/archives/"
            rel="noopener noreferrer"
            target="_self"
            >
            博客
          </a>
        </li>
      
        <li class="item-toolbox">
          <a
            class="CIRCLE"
            href="/categories/"
            rel="noopener noreferrer"
            target="_self"
            >
            分类
          </a>
        </li>
      
        <li class="item-toolbox">
          <a
            class="CIRCLE"
            href="/tags/"
            rel="noopener noreferrer"
            target="_self"
            >
            标签
          </a>
        </li>
      
        <li class="item-toolbox">
          <a
            class="CIRCLE"
            href="/search/"
            rel="noopener noreferrer"
            target="_self"
            >
            搜索
          </a>
        </li>
      
        <li class="item-toolbox">
          <a
            class="CIRCLE"
            href="/link/"
            rel="noopener noreferrer"
            target="_self"
            >
            友链
          </a>
        </li>
      
        <li class="item-toolbox">
          <a
            class="CIRCLE"
            href="/about/"
            rel="noopener noreferrer"
            target="_self"
            >
            关于
          </a>
        </li>
      
    </ul>
  </div>


</div>


  <div id="toc" class="toc-article">
    <strong class="toc-title">文章目录<i class="iconfont toc-title" style="display:inline-block;color:#87998d;width:20px;height:20px;">&#xf004b;</i></strong>
    <ol class="toc"><li class="toc-item toc-level-3"><a class="toc-link" href="#第一部分：数据库相关概念"><span class="toc-text">第一部分：数据库相关概念</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#第二部分：查询"><span class="toc-text">第二部分：查询</span></a></li></ol>
  </div>
  




<div class="content content-post CENTER">
   <!-- canvas 彩带 -->
<canvas id="evanyou" width="1302" height="678" style="position: fixed;width: 100%;height: 100%;top: 0;left:0;z-index:-1;"></canvas>

<article id="post-SqlServer2005学习总结" class="article article-type-post" itemprop="blogPost">
  <header class="article-header" style="position:relative;">
    <h1 class="post-title">SqlServer2005学习总结</h1>

    <div class="article-meta">
      <span>
        <i class="icon-calendar"></i>
        <span>2016.05.17</span>
      </span>

      
        <span class="article-author">
          <i class="icon-user"></i>
          <span>Poetry</span>
        </span>
      

      
  <span class="article-category">
    <i class="icon-list"></i>
    <a class="article-category-link" href="/categories/DataBase/">DataBase</a>
  </span>



      

      
      <i class="fa fa-eye"></i> 
        <span id="busuanzi_container_page_pv">
           &nbsp热度 <span id="busuanzi_value_page_pv">
           <i class="fa fa-spinner fa-spin"></i></span>℃
        </span>
      
      
       
          <span class="post-count">
            <i class="fa fa-file-word-o"></i>&nbsp
            <span>字数统计 6k字</span>
          </span>

          <span class="post-count">
            <i class="fa fa-columns"></i>&nbsp
            <span>阅读时长 23分</span>
          </span>
      
      
    </div>

    <i class="iconfont" id="toc-eye" style="display:inline-block;color:#b36619;position:absolute;top:0;right:0;cursor:pointer;
    font-size: 24px;">&#xe61c;</i>

  </header>

  <div class="article-content">
    
      <div id="container">
        <h3 id="第一部分：数据库相关概念"><a href="#第一部分：数据库相关概念" class="headerlink" title="第一部分：数据库相关概念"></a><strong>第一部分：数据库相关概念</strong></h3><p><strong>什么是数据库</strong><br><a id="more"></a></p>
<ul>
<li><p>狭义:</p>
<ul>
<li>存情数据的仓库</li>
</ul>
</li>
<li><p>广义:</p>
<ul>
<li>可以对数据进行存储和管理的软件以及数据本身统称为数据库</li>
</ul>
</li>
</ul>
<p>数据库是由表、  关系、  操作组成</p>
<p><strong>为什么需要数据库</strong></p>
<ul>
<li>几乎所有的应用软件的后台都需要数据库</li>
<li>数据库存储数据占用空间小容易持久保存</li>
<li>存储比较安全</li>
<li>容易维护和升级</li>
<li>数据库移植比较容易</li>
<li>简化对数据的操作</li>
<li>为将来学习0racle做准备</li>
<li><p>B/s架构里面包含数据库<br><strong>数据库的安装和卸载</strong></p>
</li>
<li><p>sq12000</p>
</li>
<li>解决挂起的问题</li>
</ul>
<p><strong>预备知识</strong></p>
<ul>
<li>学习SqlServer2005必须的先学一门编程语言么</li>
<li>不需要,但是懂一门编程语言的话会有助于学习sqlserver2005 的TL SQ</li>
</ul>
<p><strong>数据结构和数据库的区别</strong></p>
<ul>
<li>数据库是在应用软件级别研究数据的存储和操作数据结构是在系统软件级别研究数据的存储和操作</li>
</ul>
<p><strong>什么是连接 【重点】</strong></p>
<ul>
<li>有了编程语言为什么还需要数据库</li>
<li>对内存数据操作是编程语言的强项,   但是对硬盘数据操作却是编程语言的弱项对硬盘数据操作是数据库的强项, 是数据库研究的核心同题</li>
</ul>
<p><strong>建议初学者从三个方面学习数据库数据库是如何存储数据的</strong></p>
<ul>
<li>字段记录表约束(主键外键唯一键非空 check default触发器)</li>
<li><p>数据库是如何操作数据的<br><code>insert  update delete T-SQL</code> 存储过程函数触发器</p>
</li>
<li><p>数据库是如何显示数据的<br><code>select</code>(重点的重点)</p>
</li>
</ul>
<p><strong>必各的一些操作</strong></p>
<ul>
<li>如何建数据库</li>
<li>如何删除数据库</li>
<li>如何附加和分高数据库</li>
<li>设置登录用户名和密码</li>
<li>如何创建用户</li>
</ul>
<p><strong>数据库是如何解决数据存储问题的 【最基础内容, 必须掌握】</strong></p>
<p><strong>1.表的相关数据</strong></p>
<ul>
<li><p>字段</p>
<ul>
<li>一个事物的某一个特征</li>
</ul>
</li>
<li><p>记录</p>
<ul>
<li>字段的组合表示的是一个具体的事物</li>
</ul>
</li>
<li><p>表</p>
<ul>
<li>记录的组合表示的是同一类型事物的集合</li>
</ul>
</li>
</ul>
<p><strong>表和字段、记录的关系</strong></p>
<ul>
<li>字段是事物的属性</li>
<li>记录是事物本身</li>
<li><p>表是事物的集合</p>
</li>
<li><p>列</p>
<ul>
<li>字段的另一种称谓</li>
</ul>
</li>
<li><p>属性</p>
<ul>
<li>字段的另一种称谓</li>
</ul>
</li>
<li><p>元组</p>
<ul>
<li>记录的另一种称谓</li>
</ul>
</li>
</ul>
<p><strong>2.   create table命令</strong></p>
<ul>
<li>通过图形化界面建表<br>create table最后一个字段的后面建议不要写逗号说明:简単掌握后面我们会再详细的介绍</li>
</ul>
<p><strong>3.    什么是约束</strong></p>
<ul>
<li><p>定义</p>
<ul>
<li>对一个表中属性操作的限制叫做约束</li>
</ul>
</li>
<li><p>分类</p>
<ul>
<li>主键约束<br>不允许重复元素選免了数据的冗余</li>
</ul>
</li>
<li><p>外键约束</p>
<ul>
<li>通过外键约束从语法上保证了本事物所</li>
<li>关联的其他事物一定是存在的</li>
</ul>
</li>
</ul>
<p>事物和事物之间的关系是通过外键来体现的</p>
<ul>
<li><p>check约束</p>
<ul>
<li>保证事物属性的取值在合法的范围之内</li>
</ul>
</li>
<li><p>default约束</p>
<ul>
<li>保证事物的属性一定会有一个值</li>
</ul>
</li>
<li><p>唯一约束</p>
<ul>
<li>保证了事物属性的取值不允许重复,,但允许其中有一列且只能有一列为空</li>
</ul>
</li>
</ul>
<p><strong>间题:</strong></p>
<p>ul,i que键是否允许多列为空?</p>
<p>答:</p>
<ul>
<li>SqlServer2005只允许一个uni que列为空</li>
<li>Oracle1 IG允许多个uni que列为空</li>
</ul>
<p><strong>not null</strong></p>
<ul>
<li>要求用户必须的为该属性赋一个值,否则语法出错!</li>
</ul>
<ul>
<li>如果一个字段不写n,11也不行not n,11</li>
<li>则默认是rm11即默认允许为空,用户可以不给该字段赋值</li>
<li>如果用户没有为该字段赋值,则该字段的值默认是nd1</li>
</ul>
<p><strong>要注意nu11和 default的区别</strong></p>
<ul>
<li>相同点:<ul>
<li>都允许用户不赋值</li>
</ul>
</li>
<li>不同点:<ul>
<li>nu11修饰的字段如果用户不赋值则默认是nu1 1</li>
<li>default修饰的字段如果用户不赋値则默认是default指定的那个值</li>
</ul>
</li>
</ul>
<p><strong>4.    表和约束的异同</strong></p>
<ul>
<li>数据库是通过表来解决事物的存備同题的</li>
<li>数据库是通过约束来解决事物取值的有效性和合法性的问题</li>
<li><p>建表的过程就是指定事物属性及其事物属性各种约束的过程</p>
</li>
<li><p>什么是关系</p>
<ul>
<li>定义:<br>表和表之间的联系</li>
</ul>
</li>
<li><p>实现方式</p>
<ul>
<li>通过设置不同形式的外键来体现表和表的不同关系</li>
</ul>
</li>
<li><p>分类(假设是A表和B表)</p>
<ul>
<li><p>一对一<br>既可以把表A 的主键充当表B的外键<br>也可以把表B的主键充当表A的外键</p>
</li>
<li><p>一对多【重点】<br>把表A 的主键充当表B的外键<br>或者讲: 把A表的主键添加到B表来充当B表的外键</p>
</li>
</ul>
</li>
</ul>
<p>在多的一方添加外键</p>
<ul>
<li>多对多<br>多对多必须的通过単独的一张表来表示</li>
</ul>
<p><strong>例子</strong></p>
<ul>
<li>班级和教师</li>
<li>班级是一张表</li>
<li>教师是一张表</li>
<li>班级和教师的关系也是一张表</li>
</ul>
<p><strong>6.  主键</strong></p>
<ul>
<li><p>定义</p>
<ul>
<li>能够唯一标示一个事物的一个字段或者多个字段的组合, 被称为主键</li>
</ul>
</li>
<li><p>主键的特点【重点】:</p>
<ul>
<li>含有主键的表叫做主键表</li>
<li>主键通常都是整数不建议使用字符串当主體(如果主體是用于集群式服务,才可以考虑用字符串当主體)</li>
<li>主键的值通常都不允许修改, 除非本记录被删除</li>
<li>主键不要定义成i d, 而要定义成表名 Id或者表名_i d</li>
<li>要用代理主键,不要用业务主键</li>
<li>任何一张表, 强烈建议不要使用有业务含义的字段充当主键</li>
<li>我们通常都是在表中単独添加一个整型的编号充当主键字段</li>
<li>主键是否连续增长不是十分重要</li>
</ul>
</li>
</ul>
<p><strong>7.  外键</strong></p>
<ul>
<li>定义:<ul>
<li>如果一个表中的若干个字段是来自另外若干个表的主键或唯一键<br>则这若干个字段就是外键</li>
</ul>
</li>
</ul>
<p><strong>注意:</strong></p>
<ul>
<li>外键通常是来自另外表的主键而不是唯一键, 因为唯一键可能为M11</li>
<li>外键不一定是来自另外的表, 也可能来自本表的主键</li>
<li>含有外键的表叫外建表, 外键字段来自的那一张表叫做主键表</li>
</ul>
<p><strong>问题:</strong></p>
<ul>
<li>先删主键表还是外建表?</li>
</ul>
<p>答集:  先删外建表<br>如果先删主键表,会报错,因为这会导致外建表中的数据引用失败</p>
<hr>
<h3 id="第二部分：查询"><a href="#第二部分：查询" class="headerlink" title="第二部分：查询"></a><strong>第二部分：查询</strong></h3><p><strong>査询【最重要难度最大,考试必考内容,强烈建议所有的学生都要熟练掌握査询的内容】</strong></p>
<p><strong>1.计算列</strong></p>
<figure class="highlight plain"><figcaption><span>from emp;```</span></figcaption><table><tr><td class="code"><pre><span class="line"></span><br><span class="line">- -- *表示所有的</span><br><span class="line">- -- from emp 表示从emp表査询</span><br><span class="line"></span><br><span class="line">```select empno,  ename from emp</span><br></pre></td></tr></table></figure>
<figure class="highlight plain"><figcaption><span>ename,  sa1 from emp;```</span></figcaption><table><tr><td class="code"><pre><span class="line"></span><br><span class="line">- select ename, sa1*12 as″年薪″ from emp;</span><br><span class="line">- --as可以省略记住:″年薪″不要写成&apos;年薪&apos;也不要写成年薪</span><br><span class="line"></span><br><span class="line">- select ename,  sa1*12 as″年薪″, sa1″月薪″, job from emp;</span><br><span class="line"></span><br><span class="line">```select888 from emp;</span><br></pre></td></tr></table></figure>
<p>–ok<br>-一输出的行数是emp表的行数 每行只有一个字段,</p>
<p><code>select5;</code>   –ok<br>-一不推荐</p>
<p><strong>注意:</strong></p>
<ul>
<li>在0racle中字段的别名不允许用单引号括起来</li>
<li>但是sqlserver2005却允许,,因此为了兼容性 -最好字段别名用双引号括起来, 不要用单引号</li>
</ul>
<p><strong>2.  distinct【不允许重复的】</strong></p>
<figure class="highlight plain"><figcaption><span>distinct deptno from emp;```</span></figcaption><table><tr><td class="code"><pre><span class="line">```--distince deptno会过滤掉重复的deptno</span><br></pre></td></tr></table></figure>
<figure class="highlight plain"><figcaption><span>distinct comm from emp;```</span></figcaption><table><tr><td class="code"><pre><span class="line">--distinct也可以过滤掉重复的nu11  或者说如果有多个nu11只输出一个</span><br><span class="line">```select distinct comm, deptno from emp;```-一把comm和deptno的组合进行过滤```select deptno, distinct comn from emp1```--error逻辑上有冲突</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">**3. between【在某个范围】**</span><br><span class="line"></span><br><span class="line">- -一査找工资在1 500到3000之间(包括和)的所有的员工的信息</span><br><span class="line">```select* from e1lIp</span><br><span class="line">where sa1&gt;=1500 and sa1&lt;=3000</span><br></pre></td></tr></table></figure>
<p>等价于<br><figure class="highlight plain"><figcaption><span>from emp</span></figcaption><table><tr><td class="code"><pre><span class="line">where sa1 between1500 and3000</span><br></pre></td></tr></table></figure></p>
<ul>
<li>-一査找工资小于3ooo或大于1 5oo的所有的员工的信息<figure class="highlight plain"><figcaption><span>from emp where sa1<1500 or sa1>3000```</1500></span></figcaption><table><tr><td class="code"><pre><span class="line">等价于</span><br><span class="line">```select* from emp  where sa1 not between1500 and3000</span><br></pre></td></tr></table></figure></li>
</ul>
<p><strong>4.  in【属于若干个弧立的值】</strong></p>
<p><code></code>select*from emp where sa1 in(1500,  3000,  5000)<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">等价于</span><br><span class="line">```select* from emp</span><br><span class="line">where sa1=1500 or sa1=3000 or sa1=5000</span><br></pre></td></tr></table></figure></p>
<figure class="highlight plain"><figcaption><span>emp where salnot in(1500, 3000, 5000)``` </span></figcaption><table><tr><td class="code"><pre><span class="line"></span><br><span class="line">- -一把sa1既不是也不是也不是的记录输出等价于</span><br><span class="line"></span><br><span class="line">```select* from enp</span><br><span class="line">where sa1〇1500 and sat〇3000 and sat〇5000</span><br></pre></td></tr></table></figure>
<ul>
<li>-一数据库中不等于有两种表示:   <code>!=     &lt;&gt;</code>   <strong>推荐使用第二种</strong></li>
<li>-一对或取反是并且对并且取反是或</li>
</ul>
<p><strong>5.  top【最前面的若干个记录专属于sqlserver的语法,不可移植到其他数据库】</strong></p>
<figure class="highlight plain"><figcaption><span>top5 *from emp;```</span></figcaption><table><tr><td class="code"><pre><span class="line">``select top15 percent* from emp; ```  -一输出的是3个,不是2个</span><br><span class="line">``select top5  from emp;``` --error</span><br><span class="line"></span><br><span class="line">**6. nu11【没有值空值】**</span><br><span class="line"></span><br><span class="line">- 零和rm11是不一样的, nu11表示空值,投有值,零表示一个确定的值</span><br><span class="line"></span><br><span class="line">- nu11不能参与如下运算: 〇  !=  =</span><br><span class="line">- n111可以参与如下运算:   is     not is</span><br><span class="line">- select* from emp where comm is nu11;  -一输出奖金为空的员工的信息</span><br><span class="line">```select* from emp where comm is not nu11;``` </span><br><span class="line"></span><br><span class="line">- 一输出奖金不为空的员工的信息</span><br><span class="line"></span><br><span class="line">```select* from e叩 where comm 〇 null; ```-一输出为空error</span><br><span class="line">```select*from emp where comm !=nu11; ```-一输出为空error</span><br><span class="line">```select* from emp where comm = nu11; ``` -一输出为空error</span><br><span class="line"></span><br><span class="line">- 任何类型的数据都允许为 nu1 1</span><br><span class="line"></span><br><span class="line">```create table t1 (:l,lamenvarchar(20), cnt int, riqi datetime);</span><br><span class="line">insert into t1 values(nu1l, nu11, nu11);``` -0K</span><br><span class="line"></span><br><span class="line">- 任何数字与rm1 1参与数学运算的结果永远是nu1 1</span><br><span class="line"></span><br><span class="line">- 一输出每个员工的姓名年薪(包含了奖金)   comn假设是一年的奖金</span><br><span class="line">```select empno, ename, sa1*12+comm ″年薪&quot; from emp;</span><br></pre></td></tr></table></figure>
<ul>
<li>-一本程序证明了: r,u11不能参与任何数据运算否则结果永远为空</li>
<li><p>一正确的写法是:</p>
<figure class="highlight plain"><figcaption><span>ename, sa1*12+isnu11(comm, 0)″年薪″ from emp;```</span></figcaption><table><tr><td class="code"><pre><span class="line">--is null(comm, 0)如果comm是nu11就返回零否则返回comm的值</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">**7.  order by  【以某个字段排序】**</span><br><span class="line"></span><br><span class="line">- `order by a, b`                       --a和b都是升序</span><br><span class="line">- `order by a, b desc`               --a升序 b降序</span><br><span class="line">- `order by a desc, b`        -a降序 b升序</span><br><span class="line">- `order by a desc, b desc`       --a和b都是降序</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">- 文字描述:</span><br><span class="line"> - 如果不指定排序的标准,则默认是升序升序用asc表示默认可以不写</span><br><span class="line"></span><br><span class="line"> - 为一个字段指定的排序标准并不会对另一个字段产生影响强烈建议为每一个字段都指定排序的标准</span><br><span class="line"></span><br><span class="line">**例子:**</span><br><span class="line"></span><br><span class="line"> - asc是升序的意思默认可以不写 desc是降序</span><br><span class="line"></span><br><span class="line">`select* from emp order by sa1;` 一默认是按照升序排序</span><br><span class="line"></span><br><span class="line">    select*from emp order by deptno, sa1;</span><br><span class="line"></span><br><span class="line">- -一先按照deptno升序排序,如果deptno相同,再按照sa1升序排序</span><br><span class="line"></span><br><span class="line">    select* from emp order by deptno desc, sa1;</span><br><span class="line"></span><br><span class="line">- -一先按deptno降序排序如果deptno相同再按照sal升序排序</span><br><span class="line">- -一记住sa1是升序不是降序</span><br><span class="line">`--orderby a desc, b, c, d`     desc只对a产生影响不会对后面的b  c d产生影响</span><br><span class="line"></span><br><span class="line">```select*from emp order by deptno, sa1 desc</span><br></pre></td></tr></table></figure>
</li>
<li><p>-一问题: desc是否会对deptno产生影响?</p>
</li>
<li>-一答案:不会</li>
<li>-一先按deptno升序,如果deptno相同,再按sa1降序</li>
</ul>
<p><strong>8.模糊査询 【搜索时经常使用】</strong></p>
<ul>
<li>格式:<br>select字段的集合 from表名 where某个字段的名字1ike匹配的条件<br>匹配的条件通常含有通配符</li>
</ul>
<ul>
<li><p>通配符:<br>%<br>表示任意o个或多个字符</p>
<figure class="highlight plain"><figcaption><span>emp  where enamelike'%A%'  ``` </span></figcaption><table><tr><td class="code"><pre><span class="line"></span><br><span class="line">- --ename只要含有字母A就输出</span><br><span class="line">```select*from emp where enamelike&apos;A%&apos;  ``` </span><br><span class="line"></span><br><span class="line">- -ename只要首字母是A的就输出</span><br><span class="line">```select*    from emp     where enamelike&apos;%A&apos;</span><br></pre></td></tr></table></figure>
</li>
<li><p>-ename只要尾字母是A的就输出</p>
</li>
<li><p>[这是下划线不是減号]</p>
</li>
<li><p>表示任意单个字符</p>
<figure class="highlight plain"><figcaption><span>from emp where enamelike'_A%'```</span></figcaption><table><tr><td class="code"><pre><span class="line"></span><br><span class="line">- -ename只要第二个字母是A的就输出</span><br><span class="line"></span><br><span class="line">**[a-f]**</span><br><span class="line"></span><br><span class="line">- a到f中的任意单个字符只能是a b c d e f中的任意一个字符</span><br><span class="line">`select* from emp where` </span><br><span class="line"></span><br><span class="line">- `enamelike&apos;_[A-F]%&apos;&apos;&apos;`-一把ename中第二个字符是A或B或c或D或E或F的记录输出</span><br><span class="line"></span><br><span class="line">**[a, f]**</span><br><span class="line"></span><br><span class="line">- a或f</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">**[a-c]**</span><br><span class="line"></span><br><span class="line">- 不是a也不是b也不是c的任意单个字符</span><br><span class="line"></span><br><span class="line">`select* from emp where enamelike&apos;_[A-F]%&apos;&apos;&apos;`-一把ename中第二个字符不是A也不是B也不是c也不是D也不是E也不是F的记录输出</span><br><span class="line"></span><br><span class="line">**注意:**</span><br><span class="line"></span><br><span class="line">- 匹配的条件必须的用单引号括起来   不能省略也不能改用双引号</span><br><span class="line">通配符作为不同字符使用的同题</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">```select* from student where namelike&apos;%\%%&apos; escape&apos;\&apos;  ``` -一把name中包含有%的输出```select* from student where namelike&apos;%\_%&apos; escape&apos;\&apos;``` 一把name中包含有_的输出</span><br><span class="line"></span><br><span class="line">**9.聚合函数【多行记录返回至一个值通常用于统计分组的信息】函数的分类**</span><br><span class="line"></span><br><span class="line">- 単行函数</span><br><span class="line"> - 每一行返回一个值</span><br><span class="line"></span><br><span class="line">- 多行函数</span><br><span class="line"> - 多行返回一个值</span><br><span class="line"> - 聚合函数是多行函数</span><br><span class="line"></span><br><span class="line"> **例子:**</span><br><span class="line">```selectlower(ename) from emp;``` 一最终返回的是行1ower0是单行函数</span><br><span class="line">`select max(sa1) from emp;` 一返回行max0是多行函数</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">**聚合函数的分类**</span><br><span class="line"></span><br><span class="line">- max()</span><br><span class="line">-min()</span><br><span class="line">-avg()  平均值</span><br><span class="line">-count()求个数</span><br><span class="line">-count(*)</span><br><span class="line"></span><br><span class="line">返回表中所有的记录的个数</span><br><span class="line"></span><br><span class="line">`select count(*) from emp;`  -一返回emp表所有记录的个数</span><br><span class="line">count(字段名)</span><br><span class="line"></span><br><span class="line">- 返回字段值非空的记录的个数, 重复的记录也会被当做有效的记录</span><br><span class="line">```select courlt(deptno) from emp;</span><br></pre></td></tr></table></figure>
</li>
<li><p>-一返回值是这说明deptno重复的记录也被当做有效的记录</p>
<figure class="highlight plain"><figcaption><span>coul,it(l1omm) from emp;``</span></figcaption><table><tr><td class="code"><pre><span class="line"></span><br><span class="line">- -一返回値是这说明 c omm为ru」1 1的记录不会被当做有效的记录</span><br><span class="line"></span><br><span class="line">- count(distinct字段名)</span><br><span class="line"> - 返回字段不重复并且非空的记录的个数</span><br><span class="line"></span><br><span class="line">```select count(distinct deptno) from emp;</span><br></pre></td></tr></table></figure>
</li>
</ul>
<p>-一返回值是 统计deptno不重复的记录的个数</p>
<p><strong>注意的问题</strong></p>
<ul>
<li>判断如下sq1语句是否正确</li>
</ul>
<figure class="highlight plain"><figcaption><span>ma:x(sa1), min(sa1), count(*) from emp; ```--ok</span></figcaption><table><tr><td class="code"><pre><span class="line">select max(sa1) -最高工资″, min(sa1)″最低工资″, count(*)″员工人数″ from emp; --ok</span><br><span class="line">```select max(sa1), 1ower(ename) from emp;``` --error单行函数和多行函数不能混用</span><br><span class="line">```select ma;x(sa1) from emp;``` --ok默认把所有的信息当做一组</span><br><span class="line"></span><br><span class="line">**10. group by  【分组难点】**</span><br><span class="line"></span><br><span class="line">- 格式:</span><br><span class="line"> - group by字段的集合</span><br><span class="line"></span><br><span class="line">- 功能:</span><br><span class="line"> - 把表中的记录按照字段分成不同的组</span><br><span class="line"></span><br><span class="line">**例子**</span><br><span class="line"></span><br><span class="line">- 査询不同部门的平均工资</span><br><span class="line">```select deptno, avg(sa1)</span><br></pre></td></tr></table></figure>
<p>as″部门平均工资⊠   from emp group by deptno</p>
<p><strong>注意:</strong></p>
<ul>
<li>理解:  gro·up by a, b, c的用法</li>
<li>先按a分组,如果a相同,再按b分组,如果b相同,再按c分组</li>
<li>最终统计的是最小分组的信息</li>
<li>一定要明自下列语句为什么是错误的</li>
</ul>
<p>select deptno, avg(sa1) as″部门平均工资⊠, ename<br>from emp<br>解oup by deptno</p>
<p>select deptno,  ename<br>from emp<br>解oup by deptno</p>
<p>select deptno, job, sa1<br>from emp<br>解oup by deptno, job<br>记住:使用了gro1」p by之后select 不能出现组内的详细信息中只能出现分组后的整体信息,</p>
<p><strong>11. having【对分组之后的信息进行过滤难点】</strong></p>
<ul>
<li><p>having子句是用来对分组之后的数据进行过滤<br>因此使用having时通常都会先使用group by</p>
</li>
<li><p>如果没使用gro·L!p by但使用了having<br>则意味着having把所有的记录当做一组来进行过滤<br>极少用</p>
<figure class="highlight plain"><figcaption><span>count(*)</span></figcaption><table><tr><td class="code"><pre><span class="line">from emp</span><br><span class="line">having avg(sa1) &gt; 1000</span><br></pre></td></tr></table></figure>
</li>
<li><p>having子句出现的字段必须的是分组之后的组的整体信息having子句不允许出现组内的详细信息</p>
</li>
<li><p>尽管select字段中可以出现别名</p>
</li>
<li>但是having子句中不能出现字段的别名, </li>
<li><p>只能使用字段最原始的名字原因不得而知</p>
</li>
<li><p><strong>having和where的异同</strong></p>
</li>
<li><p>相同的:</p>
<ul>
<li><p>都是对数据过滤,只保留有效的数据<br>where和having一样, </p>
</li>
<li><p>都不允许出现字段的别名,,只允许出现最原始的字段的名字,本结论在S‘11Server2005和Olracle11G都成立</p>
</li>
</ul>
</li>
<li>不同:<ul>
<li>where是对原始的记录过滤 having是对分组之后的记录过滤</li>
<li>where必须的写在having的前面,顺序不可颠倒否则运行出错</li>
</ul>
</li>
</ul>
<p><strong>例子:</strong></p>
<p>一把工资大于,<br>-一统计输出部门平均工资大于的部门的部门编号部门的平均工资select deptno, avg(sa1)″平均工资″, count(*)″部门人数″,,max(sa1) ″部门的最高工资″<br>from emp<br>where sa1 &gt;2000  –where是对原始的记录过滤<br>group by deptno<br>having avg(sa1) &gt; 3000  -一对分组之后的记录过滤</p>
<p>一判断入选语句是否正确</p>
<blockquote>
<p>select deptno, avg(sal)″平均工资″, count(*)″部门人数″,,max(sa1) ″部门的最高工资″ from<br>emp group by deptno having avg(sa1) &gt;3000  -一对分组之后的记录过滤 where sa1 &gt;<br>2000  一一where写在了having的后面  error</p>
</blockquote>
<p><strong>12.连接査询</strong></p>
<ul>
<li><p>定义</p>
<ul>
<li>将两个表或者两个以上的表以一定的连接条件连接起来</li>
<li>从中检索出满足条件的数据</li>
</ul>
</li>
<li><p>分类</p>
</li>
</ul>
<p><strong>内连接【重点的重点也是难点的难点】</strong></p>
<ul>
<li><ol>
<li><code>select... fromA, B</code>的用法<br>产生的结果:</li>
</ol>
</li>
<li>行数是A和B的乘积</li>
<li><p>列数是A和B之和</p>
</li>
<li><p>或者说<br>油表的每一条记录都和B表的每一条记录组合在一起形成的是个笛卡尔积</p>
</li>
<li><p>或者说:</p>
<ul>
<li>把B表的每一条记录都和A表的每一条记录组合在一起形成的是个笛卡尔积</li>
</ul>
</li>
</ul>
<p><strong>注意:</strong></p>
<figure class="highlight plain"><figcaption><span>from A, B```</span></figcaption><table><tr><td class="code"><pre><span class="line">输出结果和</span><br><span class="line">```select* from B, A</span><br></pre></td></tr></table></figure>
<p>是一模一样的</p>
<p><strong>例子</strong><br>-一输出70行11列<br><figure class="highlight plain"><figcaption><span>from emp, dept```</span></figcaption><table><tr><td class="code"><pre><span class="line"></span><br><span class="line">**2. select... from A, Bwhere... 的用法**</span><br><span class="line"></span><br><span class="line">```select... from A, B ``` --A和B可以互换</span><br><span class="line">产生的簡卡尔积, 用where中的条件进行过滤</span><br><span class="line">**例子:**</span><br><span class="line">-一输出5行11列</span><br><span class="line">select*</span><br><span class="line">from emp, dept  --dept和emp互换输出结果不变</span><br><span class="line">where empno= 7369</span><br><span class="line"></span><br><span class="line">-   select... from A join B on... select...  from A join B on</span><br><span class="line">-  SQL92标准和 SQL99标准的区别</span><br><span class="line">```select...  from A, B where.</span><br></pre></td></tr></table></figure></p>
<figure class="highlight plain"><figcaption><span>from A join B on```</span></figcaption><table><tr><td class="code"><pre><span class="line">输出结果是一样</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">**推荐使用 sQL99标准**</span><br><span class="line"></span><br><span class="line">- sq199更容易理解</span><br><span class="line">- 在sq199标准中, on和,rhere可以做不同的分工</span><br><span class="line">on指定连接条件</span><br><span class="line">where对连接之后临时表的数据进行过糖</span><br><span class="line"></span><br><span class="line">**示例:**</span><br><span class="line"></span><br><span class="line">一把工资大于2000的员工的姓名和部门的名称输出 和 工资的等级</span><br><span class="line">-sc1199标准明显的优于sq192</span><br><span class="line"></span><br><span class="line">    select″E″.enae,″D″.hme,″S&quot;.grade</span><br><span class="line">    from e叩 &quot;E″</span><br><span class="line">    join dept″D″</span><br><span class="line">    on″E″.deptno=″D〟.deptno</span><br><span class="line">    Join salgrade″S″</span><br><span class="line">    on″E″.sa1&gt;=″S″.1osal md&quot;E″.sa1 &lt;=″S″.hisal</span><br><span class="line">    where″E&quot;.sa1 &gt; 2000</span><br><span class="line"></span><br><span class="line">一把工资大于2ooo的员工的姓名和部门的名称输出 和 工资的等级-sq192标准</span><br><span class="line"></span><br><span class="line">    select″E″.en訓e,″D″.如ae,″S″.grade</span><br><span class="line">    from e叩 ″E″, dept&quot;D〟, salpade″S″</span><br><span class="line">    where″E&quot;,sa1 &gt; 2000  md  &quot;E″,deptno=″D″,deptno md</span><br><span class="line">    (″E″.sa1&gt;=″S″.1osa1 md -E″.sa1 &lt;=″S″.hisa1)</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">**5.  select、   from、   where、   Join、   on、   group、     order、   top、   having的混合使用**</span><br><span class="line"></span><br><span class="line">**査询的顺序**</span><br><span class="line"></span><br><span class="line">- select top....</span><br><span class="line">- from A</span><br><span class="line">- join B</span><br><span class="line">- on....</span><br><span class="line">- join C</span><br><span class="line">- on....</span><br><span class="line">- where,.....</span><br><span class="line">- group by...</span><br><span class="line">- having. , , . .</span><br><span class="line">- order by.....</span><br><span class="line">**例子:**</span><br><span class="line"></span><br><span class="line">- -一把工资大于的所有的员工按部门分组把部门平均工资大于的最</span><br><span class="line">- -一高前个的部门的编号部门的名称部 「J平均工资的等级</span><br><span class="line"></span><br><span class="line">- **一第一种写法**</span><br><span class="line"></span><br><span class="line">&gt;     select&quot;T″,*,  &quot;D″,如ae,  &quot;S″.grade</span><br><span class="line">&gt;     from dept″D″</span><br><span class="line">&gt;     join(select top2″E&quot;.deptno,  avg(sa1)″avg_sa1″</span><br><span class="line">&gt;     from emp″E″</span><br><span class="line">&gt;     join dept″D″</span><br><span class="line">&gt;     on″E″.deptno=″D&quot;.deptno</span><br><span class="line">&gt;     Join salpade″S&quot;</span><br><span class="line">&gt;     on -E″.sa1 between〃S&quot;.1osa1 nd″S&quot;.hisa1</span><br><span class="line">&gt;     where ⊠E&quot;.sa1 &gt; 1500</span><br><span class="line">&gt;     group by ⊠E″.deptno</span><br><span class="line">&gt;     having avg(″E〟.sat) &gt; 2000</span><br><span class="line">&gt;     order by avg(&quot;E&quot;.sat) desc</span><br><span class="line">&gt;     ) ″T″</span><br><span class="line">&gt;     on&quot;D〟.deptno=″T″.deptno</span><br><span class="line">&gt;     imer join salgrade″S&quot;</span><br><span class="line">&gt;     on″T&quot;.″avg_sa1&quot; between&quot;S″.1osa1 nd&quot;S″.hisa1</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">- **一第二种写法**</span><br><span class="line"></span><br><span class="line">&gt; select″T-.*,  ″D-. hae,  ″S&quot;.grade from dept″D″ join(select top2</span><br><span class="line">&gt; deptno,  avg(sa1)    as″avg_sa1″ from emp where sa1 &gt; 1500 group by</span><br><span class="line">&gt; deptno having avg(sa1)  &gt; 2000 order by″avg_sa1″ desc )  ″T″</span><br><span class="line">&gt; on″D″.deptno=″T″.deptno Join salgrade″S&quot; on″T&quot;.″avg_sa1″</span><br><span class="line">&gt; between″S″.1osa1 nd″S″,hisal</span><br><span class="line"></span><br><span class="line">**6. 习题**</span><br><span class="line"></span><br><span class="line">- 判断以下语句输出是几行</span><br><span class="line">```select&apos;l: from emp, dept where emp.deptno= 10</span><br></pre></td></tr></table></figure>
<figure class="highlight plain"><figcaption><span>from emp, dept where dept.deptno</span></figcaption><table><tr><td class="code"><pre><span class="line"></span><br><span class="line">- -一过滤条件不是连接条件</span><br><span class="line"></span><br><span class="line">考虑如何把</span><br><span class="line">selelit:* from emp, dept where dept.dept:lio= 10 以sq199标准来输出</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">1&gt;求出每个员工的姓名部门编号薪水和薪水的等级</span><br><span class="line">2&gt;査找每个部门的编号该部门所有员工的平均工资平均工资的等级</span><br><span class="line">3&gt;査找每个部门的编号部门名称该部门所有员工的平均工资平均工资的等级</span><br><span class="line">4&gt;求出emp表中所有领导的信息</span><br><span class="line">5&gt; 求出平均薪水最高的部门的编号和部门的平均工资</span><br><span class="line">6&gt;把工资大于所有员工中工资最低的前3个人的姓名工资部门编号部门名称工资等级输出</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">**自连接**</span><br><span class="line"></span><br><span class="line">- 定义</span><br><span class="line"> - 一张表自己和自己连接起来査询数据</span><br><span class="line"></span><br><span class="line"> **例子**</span><br><span class="line"> </span><br><span class="line">- 不准用聚合函数求薪水最高的员工的信息</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">**联合**</span><br><span class="line"></span><br><span class="line">- 定义</span><br><span class="line"> - 表和表之间的数据以纵向的方式连接在一起</span><br><span class="line"> - **注意:** 我们以前讲的所有的连接是以横向的方式连接在一起的</span><br><span class="line"></span><br><span class="line">**例子:**</span><br><span class="line"></span><br><span class="line">- 输出每个员工的姓名工资上司的姓名</span><br><span class="line"></span><br><span class="line">```select&quot;E1″,enae,″E1″.sa1,   ″E2″.en訓e″上司的姓名″</span><br><span class="line">from emp″E1″</span><br><span class="line">Join emp″磁″</span><br><span class="line">on&quot;E1&quot;.m解 =″E2″.empno</span><br><span class="line">uni on</span><br><span class="line">select ename, sa1, &apos;已是最大老板&apos; from emp where mgr is nul1</span><br></pre></td></tr></table></figure>
<p><strong>注意:</strong></p>
<ul>
<li>若干个select子句要联合成功的话,必须的满足两个条件<ul>
<li>这若干个select子句输出的列数必须是相等的</li>
<li>这若干个se1 ect子句输出列的数据类型至少是兼容的</li>
</ul>
</li>
</ul>
<p><code>identity</code>【主键自动增长,用户不需要为identity修饰的主键赋值】<br>用户如何手动给被i dent i ty修饰的主键赋值不重要</p>
<p>表中删除数据后又插入数据会导致主键不连续递增 怎么办?<br>主键是否连续增长不十分重要</p>
<p><strong>视图</strong></p>
<ul>
<li>为什么需要视图</li>
</ul>
<p><strong>示例</strong></p>
<ul>
<li><p>求出平均工资最高的部门的编号和部门的平均工资</p>
</li>
<li><p><strong>总结:</strong></p>
<ul>
<li>简化査询</li>
<li>避免了代码的冗余</li>
<li>避免了书写大量重复的sq1语句</li>
</ul>
</li>
</ul>
<ul>
<li>什么是视图</li>
<li>视图从代码上看是一个select语句</li>
<li>视图从逻辑上看被当做一个虚拟表看待</li>
</ul>
<ul>
<li><strong>如何创建视图</strong></li>
</ul>
<p><code>create view</code>视图的名字<br>as<br>-se1 ect的前面不能添加begin<br>select语句<br>-se1 ect的后面不能添加end</p>
<p><strong>注意的问题</strong></p>
<ul>
<li>创建视图的 se1 ec t语句必须的为所有的计算列指定别名<br>-error<br>create view v$_a<br>as<br>select avg(sa1) from emp;</li>
</ul>
<p>-ok<br>create view v$_a</p>
<p>as<br>select avg(sa1) as ⊠avg_sa1″ from emp;</p>
<ul>
<li>视图不是物理表,是虚拟表</li>
<li>不建议通过视图更新视图所依附的原始表的数据或结构</li>
</ul>
<ul>
<li><p><strong>视图的优点</strong></p>
<ul>
<li>简化査询</li>
<li>增加数据的保密性</li>
</ul>
</li>
<li><p><strong>视图的缺点</strong></p>
<ul>
<li>增加了数据库维护的成本</li>
<li>视图只是简化了査询,但是并不能加快査询的速度这也是视图使用不足的地方</li>
</ul>
</li>
</ul>
<p><strong>事务【重要】</strong></p>
<ul>
<li>初学者必须要理解的三个概念</li>
<li><p>事务是用来研究什么的</p>
<ul>
<li>避免数据处于不合理的中间状态</li>
<li>转账</li>
</ul>
</li>
<li><p>怎样保证多用户同时访间同一个数据时呈现给用户的数据是合理的<br>很复杂,现在人类仍然投有设计出很好的解决办法!</p>
</li>
<li><p><strong>事务和线程的关系</strong></p>
<ul>
<li>事务是通过锁来解决并发访问的</li>
<li>线程同步也是通过锁来解决并发访同的  synchronized</li>
</ul>
</li>
</ul>
<p>所谓并发访同是指: 多用户同时访同同一个数据</p>
<ul>
<li><p><strong>事务和第三方插件的关系</strong></p>
<ul>
<li>直接使用事务库技术难度很大 很多人是借助第三放插件来实现</li>
<li>因此我们一般人不需要细细的研究数据库中事务的语法细节</li>
</ul>
</li>
<li><p>第三方插件要想完成预期的功能,   一般必须的借助数据库中的事物机制来实现</p>
</li>
</ul>
<hr>
<ul>
<li>索引</li>
<li>存储过程游标</li>
<li>TL_SQL 触发器</li>
</ul>
<ul>
<li><p><strong>分页査询</strong></p>
<ul>
<li>总结</li>
</ul>
</li>
</ul>
<p>假设每页显示n条记录, 当前要显示的是第m页<br>表名是A  主键是A_id<br>select top n<em><br>from A<br>where A_id not in(select top  (m-1)</em>n   A_id from emp)</p>

      </div>
    
  </div>

</article>

<button class="assist-btn2 circle" id="assist_btn2" title="点亮屏幕" style="left: 27px; top: 152px;">
  <i class="iconfont" style="display:inline-block;color:red;width:20px;height:20px;">&#xe61d;</i>
</button>
<button class="assist-btn1 circle" id="assist_btn1" title="关闭屏幕亮度" style="left: 27px; top: 152px;">
  <i class="iconfont toc-title" style="display:inline-block;color:red;width:20px;height:20px;">&#xe61d;</i>
</button>


<script src="//cdn.bootcss.com/jquery/3.1.1/jquery.min.js"></script>	

<script src="https://my.openwrite.cn/js/readmore.js" type="text/javascript"></script>
<script>
  const btw = new BTWPlugin();
  btw.init({
    id: "container",
    blogId: "22699-1592137983091-414",
    name: "前端进阶之旅",
    qrcode: "https://poetries1.gitee.io/img-repo/2020/06/qrcode.jpg",
    keyword: "3a3b3c",
  });
</script>

<script type="text/javascript">

// white theme
var body = {color: "#555", background: "#000"};
var a_tag = {color: "#222"};
var header = { background: "#222"};
var logo_line_i = {background: "#222"};
// var post_code = {background: "#eee", color: "#222"};

function switch_theme() {
 $("body").css(body);
 $("a:not('.links-of-author-item a, .site-state-item a, .site-state-posts a, .feed-link a, .motion-element a, .post-tags a, .show-commit-cls a, #donate_board a')").css(a_tag);
 $(".header, .footer").css(header);
 $(".logo-line-before i, .logo-line-after i").css(logo_line_i);
 //$(".post code").css(post_code);
 $("#idhyt-surprise-ball #idhyt-surprise-ball-animation .drag").css(a_tag);
 $(".post-title-link, .posts-expand .post-meta, .post-comments-count, .disqus-comment-count, .post-category a, .post-nav-next a, .post-nav-item a").css(a_tag);
 
 // $("code").css({color: '#c5c8c6', background: '#1d1f21'});
 //$("#assist_btn1").hide(1500);
}

$(function () {
$("#assist_btn2").css("display","none");
 $("#assist_btn1").click(function() {
     switch_theme();
$("div#toc.toc-article").css({
 "background":"#eaeaea",
 "opacity":1
});
$(".toc-article ol").show();
$("#toc.toc-article .toc-title").css("color","#a98602");
$("#assist_btn1").css("display","none");
$("#assist_btn2").css("display","block");
 });
$("#assist_btn2").click(function() {
$("#assist_btn2").css("display","none");
$("#assist_btn1").css("display","block");
$("body").css("background","url(http://www.miaov.com/static/ie/images/news/bg.png)")
     $(".header, .footer").css("background","url(http://www.miaov.com/static/ie/images/news/bg.png)")
$(".toc-article ol").toggle(1000);
 });
});


//背景随机

var Y, O, E, L, B, C, T, z, N, S, A, I;
!function() {
var e = function() {
for (O.clearRect(0, 0, L, B), T = [{
x: 0,
y: .7 * B + C
}, {
x: 0,
y: .7 * B - C
}]; T[1].x < L + C;) t(T[0], T[1])
}, t = function(e, t) {
O.beginPath(), O.moveTo(e.x, e.y), O.lineTo(t.x, t.y);
var n = t.x + (2 * I() - .25) * C,
 r = a(t.y);
O.lineTo(n, r), O.closePath(), N -= S / -50, O.fillStyle = "#" + (127 * A(N) + 128 << 16 | 127 * A(N + S / 3) + 128 << 8 | 127 * A(N + S / 3 * 2) + 128).toString(16), O.fill(), T[0] = T[1], T[1] = {
 x: n,
 y: r
}
}, a = function n(e) {
var t = e + (2 * I() - 1.1) * C;
return t > B || t < 0 ? n(e) : t
};
Y = document.getElementById("evanyou"), O = Y.getContext("2d"), E = window.devicePixelRatio || 1, L = window.innerWidth, B = window.innerHeight, C = 90, z = Math, N = 0, S = 2 * z.PI, A = z.cos, I = z.random, Y.width = L * E, Y.height = B * E, O.scale(E, E), O.globalAlpha = .6, document.onclick = e, document.ontouchstart = e, e()
}()

   
$("#toc-eye").click(function(){
$("#toc.toc-article").toggle(1000);
});

</script>


   
  <div class="text-center donation">
    <div class="inner-donation">
      <span class="btn-donation">支持一下</span>
      <div class="donation-body">
        <div class="tip text-center">扫一扫，支持poetries</div>
        <ul>
        
          <li class="item">
            
              <span>微信扫一扫</span>
            
            <img src="/images/weixin.jpg" alt="">
          </li>
        
          <li class="item">
            
              <span>支付宝扫一扫</span>
            
            <img src="/images/zhifubao.jpg" alt="">
          </li>
        
        </ul>
      </div>
    </div>
  </div>


   
  <div class="box-prev-next clearfix">
    <a class="show pull-left" href="/2016/04/30/排序算法总结/">
        <i class="icon icon-angle-left"></i>
    </a>
    <a class="show pull-right" href="/2016/05/20/HTML5-CSS3-最酷的-loading-效果收集/">
        <i class="icon icon-angle-right"></i>
    </a>
  </div>




</div>


  <a id="backTop" class="back-top">
    <i class="icon-angle-up"></i>
  </a>




  <div class="modal" id="modal">
  <span id="cover" class="cover hide"></span>
  <div id="modal-dialog" class="modal-dialog hide-dialog">
    <div class="modal-header">
      <span id="close" class="btn-close">关闭</span>
    </div>
    <hr>
    <div class="modal-body">
      <ul class="list-toolbox">
        
          <li class="item-toolbox">
            <a
              class="CIRCLE"
              href="/archives/"
              rel="noopener noreferrer"
              target="_self"
              >
              博客
            </a>
          </li>
        
          <li class="item-toolbox">
            <a
              class="CIRCLE"
              href="/categories/"
              rel="noopener noreferrer"
              target="_self"
              >
              分类
            </a>
          </li>
        
          <li class="item-toolbox">
            <a
              class="CIRCLE"
              href="/tags/"
              rel="noopener noreferrer"
              target="_self"
              >
              标签
            </a>
          </li>
        
          <li class="item-toolbox">
            <a
              class="CIRCLE"
              href="/search/"
              rel="noopener noreferrer"
              target="_self"
              >
              搜索
            </a>
          </li>
        
          <li class="item-toolbox">
            <a
              class="CIRCLE"
              href="/link/"
              rel="noopener noreferrer"
              target="_self"
              >
              友链
            </a>
          </li>
        
          <li class="item-toolbox">
            <a
              class="CIRCLE"
              href="/about/"
              rel="noopener noreferrer"
              target="_self"
              >
              关于
            </a>
          </li>
        
      </ul>

    </div>
  </div>
</div>



  
      <div class="fexo-comments comments-post">
    

    

    
    

    

    
    

    

<!-- Gitalk评论插件通用代码 -->
<div id="gitalk-container"></div>

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.css">
<script src="https://cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.js"></script>
<script>
const gitalk = new Gitalk({
  clientID: '5567a2c4abb858009d96',
  clientSecret: 'b9039ec056cf5c2346b3cdb63308a28c163f91e5',
  repo: 'poetries.github.io',
  owner: 'poetries',
  // 在这里设置一下截取前50个字符串, 这是因为 github 对 label 的长度有了要求, 如果超过
  // 50个字符串则会报错.
  // id: location.pathname.split('/').pop().substring(0, 49),
  id: location.pathname,
  admin: ['poetries'],
  // facebook-like distraction free mode
  distractionFreeMode: false
})
gitalk.render('gitalk-container')
</script>
<!-- Gitalk代码结束 -->



  </div>

  

  <script type="text/javascript">
  function loadScript(url, callback) {
    var script = document.createElement('script')
    script.type = 'text/javascript';

    if (script.readyState) { //IE
      script.onreadystatechange = function() {
        if (script.readyState == 'loaded' ||
          script.readyState == 'complete') {
          script.onreadystatechange = null;
          callback();
        }
      };
    } else { //Others
      script.onload = function() {
        callback();
      };
    }

    script.src = url;
    document.getElementsByTagName('head')[0].appendChild(script);
  }

  window.onload = function() {
    loadScript('/js/bundle.js?235683', function() {
      // load success
    });
  }
</script>


  <!-- 页面点击小红心 -->
  <script type="text/javascript" src="/js/clicklove.js"></script>
 
  
</body>
</html>
